﻿using System;
using System.Collections.Generic;
using System.Linq;
using GCTrackableRace.Interfaces;
using GcTrackableRace.Entities;
using GcTrackableRace.ScoreCalculator.Helpers;

namespace GcTrackableRace.ScoreCalculator.Rules
{
	public class CountForAllDropsAndVisitsRule: BaseAllDropsAndVisitsInKmRule
	{
		public CountForAllDropsAndVisitsRule(string reportColumnName, string startDate, string endDate, string pointAllocation, IGeocacheInfo geocacheInfo)
			:base(reportColumnName, startDate, endDate, pointAllocation, geocacheInfo)
		{}
  
		protected override void SetRuleName()
		{
			RuleName = "Count for all drops and visits rule";
		}

		public override void Process(ITrackable trackable, IEnumerable<ITrackableLog> trackableLogs)
		{
			// Note : True / false does not matter as we just looking at the count
			
			var result = Calculation(trackable, trackableLogs,true); // or ,false);

			trackable.AddScore(new RuleScore(
				RuleName, 
				ReportColumnName,
				result.Item2.Count,
				(int)(result.Item2.Count * PointAllocation),
				String.Join("|", result.Item2).Trim('|')));
		}
	}
}